package java_test;

import java.lang.reflect.Field;

/**
 * 自定义bean的base对象
 */
public class baseBean implements java.io.Serializable{

    @Override
    public String toString() {
        StringBuffer ret = new StringBuffer();
        Field[] fs = this.getClass().getDeclaredFields();
        for(int i = 0; i < fs.length; ++i) {
            Field f = fs[i];
            f.setAccessible(true);
            Object val = new Object();
            try {
                val = f.get(this);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            if(ret.length() != 0) ret.append(",");
            ret.append(f.getName() + "=" + val) ;

        }
        return ret.toString();
    }
}
